home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
.net (Turkey) 1998 March
/
.net Internet Dergisi - CD 5.iso
/
mac
/
CON_BM
/
00294_Script_294
< prev
next >
Wrap
Text File
|
1997-11-07
|
2KB
|
58 lines
--Volume control bit
-- this gets a decimal value for the position of the handle on the slide.
-- the position is calculated as the location of the handle
-- - half it's width divided by the total length of the slide to a
-- value of 1 decimal point.
-- Finer results can be achieved with a longer slide and/or a higher
-- floatPrecision value.
-- The code is independent of the size of the slide. You're free
-- to create any size slide to fit your needs.
-------------
on sliderV slideSprite,theFld
-- this handler deals with vertical sliders
set handleSprite = the clickOn
puppetSprite handleSprite, true
set h = the height of sprite slideSprite
-- this is the basis for calculating the value that
-- the slider returns
set the floatPrecision to 1
-- the floatPrecision sets the decimal value for the
-- calculation below.
repeat while the stillDown
set the locV of sprite handleSprite = constrainV(slideSprite, (the mouseV - 10))
updateStage
-- this just places the handle on the slide. It's
-- constrained to move only along the slide sprite.
set vPos = the locV of sprite handleSprite
-- get the final location of the handle
-- set howFarV = ((float(the bottom of sprite slideSprite - vPos) / h) * 100)
-- put howFarV into field theFld
-- this calculation returns a value from 0 to 100
set howFarV = integer ((float(the bottom of sprite slideSprite - vPos) / h) * 255)
if the movieName = "con_mm" then
set the volume of sound 2 to howFarV
else
set the volume of sprite 48 to howFarV
end if
put howFarV into field theFld
-- this calculation returns a value from 0 to 255 in
-- integers, no decimal places
end repeat
updatestage
end
-- the position is calculated as the location of the handle
-- - half it's height divided by the total length of the
-- slide to a value of 1 decimal point.
-- Finer results can be achieved with a longer slide and/or
-- a higher floatPrecision value.
-- The code is independent of the size of the slide. You're
-- free to create any size slide to fit your needs.
-------------